
import os
from pyo3_demo import *
import time
from scapy.all import *

def main():
    # pyany
    # packet = IP(dst="github.com") / ICMP()
    # print(py_any(packet))

    # pydict
    # workers = {"Jack": 1, "Rose":2, "Tom":3}
    # print(py_dict(**workers))

    # pyimport
    # print(py_import(time))

    # with_gil
    # with_gil()

    # randint
    print(randint(1, 100))

    pass

def append_timestamp_to_file(filename):
    # 定义变量文件路径
    file_path = "target/counter"

    # 检查文件是否存在，如果不存在则创建并初始化为1
    if not os.path.exists(file_path):
        with open(file_path, "w") as f:
            f.write("1")

    # 读取文件中的值并递增
    with open(file_path, "r+") as f:
        value = int(f.read())
        value += 1
        f.seek(0)
        f.write(str(value))

    # 打印当前运行次数
    with open(filename, 'a') as f:
        f.write(f'[第{value}次实验] {__file__}\n')


if __name__ == '__main__':
    print('----------------------------------------')
    main()
    print('----------------------------------------')
    append_timestamp_to_file('tracing.log')